const path = require('path')
// const Mock = require('./mock-server/index')


function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  configureWebpack: {
    externals: {
      'vue': 'Vue',
      'element-ui': 'ELEMENT',
      'mint-ui': 'MINT',
      'axios': 'axios',
      'vue-router': 'VueRouter',
      // 'echarts': 'echarts'
    },
  },
  publicPath: process.env.NODE_ENV === 'production' ?
    // '' : '', //用mockjs 置空参数
    '/' : '/api/',
  devServer: {
    disableHostCheck: false, // 禁用webpack热重载检查 解决热更新失效问题
    proxy: {
      '/api': {
        // target: 'http://a9ckkq.natappfree.cc/',
        target: 'https://www.lzspr.com/',
        changeOrigin: true,
        secure: true, //https需要增加 表示是否校验证书
        ws: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    },
    // before(app) {
    //     Mock(app)
    // }

  },
  css: {
    loaderOptions: {
      less: {
        javascriptEnabled: true
      }
    }
  },
  //引入svg配置
  chainWebpack: config => {
    config.module
      .rule('svg')
      .exclude.add(resolve('src/icons'))
      .end();
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      });
  },
  indexPath: path.resolve(__dirname, './spr/index.html'),
  outputDir: path.resolve(__dirname, './spr'),
  assetsDir: 'assets',
  // publicPath: "./",
  filenameHashing: true,
  // 生产环境 sourceMap
  productionSourceMap: false,
  lintOnSave: false
}